package com.turnengine.client.local.unit.list.count;

import static com.javabi.common.dependency.DependencyFactory.getDependency;

import java.util.ArrayList;
import java.util.List;

import com.turnengine.client.local.unit.IUnitCache;
import com.turnengine.client.local.unit.bean.IUnit;
import com.turnengine.client.local.unit.bean.IUnitCount;
import com.turnengine.client.local.unit.enums.UnitType;

public class UnitCountListSplitter implements IUnitCountListSplitter {

	public List<IUnitCount> splitList(List<IUnitCount> list, UnitType type) {
		IUnitCache cache = getDependency(IUnitCache.class);
		List<IUnitCount> typeList = new ArrayList<IUnitCount>();
		for (IUnitCount count : list) {
			IUnit unit = cache.getById(count.getId());
			if (unit.getType().equals(type)) {
				typeList.add(count);
			}
		}
		return typeList;
	}

}
